package net.roostertech.bta2dpfixer;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class A2DPReceiver extends BroadcastReceiver{
	
	private final String LOGTAG = "BTFixerA2DP";

	@Override
	public void onReceive(Context context, Intent intent) {
		BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
		int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, 0);
		int previousState = intent.getIntExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, 0);
		
		if (device == null) {
			return;
		}
		Log.i(LOGTAG, "Device " + device.getName() + " state " + previousState + " -> " + state);
		
		if (state == BluetoothAdapter.STATE_CONNECTED) {
			BluetoothClass devClass = device.getBluetoothClass();	
			Log.i(LOGTAG, "Audio " + devClass.hasService(BluetoothClass.Service.AUDIO));
			Log.i(LOGTAG, "Telephony " + devClass.hasService(BluetoothClass.Service.TELEPHONY));
		}
		
				
	}

}
